# Maintainer: Peter Budai <peterbudai at hotmail dot com>

_realname=gphoto2
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=2.5.23
pkgrel=2
pkgdesc="The gphoto2 commandline tool for accessing and controlling digital cameras. (mingw-w64)"
arch=('any')
url='http://www.gphoto.org/'
license=('GNU')
depends=("${MINGW_PACKAGE_PREFIX}-libgphoto2"
         "${MINGW_PACKAGE_PREFIX}-readline"
         "${MINGW_PACKAGE_PREFIX}-popt")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc"
             "${MINGW_PACKAGE_PREFIX}-libtool")
validpgpkeys=('7C4AFD61D8AAE7570796A5172209D6902F969C95') # Marcus Meissner
source=("https://sourceforge.net/projects/gphoto/files/gphoto/${pkgver}/${_realname}-${pkgver}.tar.gz"
        "01_gphoto_close_before_rename.patch")
sha256sums=('82100ebcc648586fcdb4aa291c2507d81020b5919094d37bd352fbfbc174fdeb'
            'ca4e431c4f2bca1272a6580ebab7d81a82fa38fad07624cc8c6328b458293b19')

prepare() {
  cd $srcdir/${_realname}-${pkgver}
  patch -p1 -i ${srcdir}/01_gphoto_close_before_rename.patch
}

build() {
  cd "$srcdir"/${_realname}-${pkgver}
  [[ -d "${srcdir}"/build-${CARCH} ]] && rm -rf "${srcdir}"/build-${CARCH}
  mkdir -p "${srcdir}"/build-${CARCH} && cd "${srcdir}"/build-${CARCH}
  ../${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST}

  make
}


package() {
  cd "${srcdir}"/build-${CARCH}
  make install DESTDIR="${pkgdir}"
}
